<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="/images/favicon.ico"  type="image/x-icon">

    <title>多选题修改</title>

    <link rel="stylesheet" type="text/css" href="/js/bootstrap-wysihtml5/bootstrap-wysihtml5.css" />
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/style-responsive.css" rel="stylesheet">


    <!--icheck-->
    <link th:href="@{/js/iCheck/skins/minimal/minimal.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/minimal/red.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/minimal/green.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/minimal/blue.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/minimal/yellow.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/minimal/purple.css}" rel="stylesheet">

    <link th:href="@{/js/iCheck/skins/square/square.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/square/red.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/square/green.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/square/blue.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/square/yellow.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/square/purple.css}" rel="stylesheet">

    <link th:href="@{/js/iCheck/skins/flat/grey.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/flat/red.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/flat/green.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/flat/blue.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/flat/yellow.css}" rel="stylesheet">
    <link th:href="@{/js/iCheck/skins/flat/purple.css}" rel="stylesheet">

    <!--富文本编辑器-->
    <link rel="stylesheet" href="/js/summernote/summernote-bs4.css" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="/js/html5shiv.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="sticky-header">

<section>

    <!--左侧开始-->
    <div th:replace="~{admin/commons/common :: commonleft}"></div>
    <!--左侧结束-->

    <!-- main content start-->
    <div class="main-content" >

        <!--头部开始-->
        <div th:replace="~{admin/commons/common :: commonheader}"></div>
        <!--头部结束-->

        <!--当前位置介绍开始-->
        <div class="page-heading">
            <h3>
                多选题修改
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">题库管理</a>
                </li>
                <li > 题目列表 </li>
                <li class="active"> 多选题修改 </li>
            </ul>
        </div>
        <!-- 当前位置介绍结束-->

        <div class="wrapper">
            <div class="mail-box">

                <section class="mail-box-info">
                    <header class="header">
                        <div class="btn-toolbar">
                            <h4 class="pull-left">
                                多选题创建中......
                            </h4>
                        </div>

                    </header>

                    <section class="mail-list">
                        <div class="compose-mail">
                            <form role="form-horizontal"  th:action="@{/admin/updateQuestion}" method="post">
                                <input style="display: none" name="id" th:value="${questionEditVM.getId()}">

                                <!--onclick函数，当管理员点击题干表单时题干表单设置不可见，显示富文本编辑器，-->
                                <div class="form-group">
                                    <label for="textarea" class="">题干:</label>
                                    <input type="text" tabindex="1" name="content" id="subject2" th:value="${questionObject.getTitleContent()}" class="form-control"
                                           onclick="editMo(this.id,this.value);" required>
                                </div>
                                &nbsp;
                                <!--富文本编辑器开始，包括按钮-->
                                <div class="compose-editor hidden">
                                    <textarea id="textarea" class="wysihtml5 form-control" rows="5" th:text="${questionObject.getTitleContent()}"></textarea>
                                </div>
                                <div class="compose-btn hidden" id="textarea-button">
                                    <button type="button" class="btn btn-primary btn-sm"
                                            onclick="$('#subject2').attr('value',$('#textarea').val());//设置题干的文本内容为富文本编辑器的内容
                                            $('#subject2').parent().removeClass('hidden')"
                                    ><i class="fa fa-check"></i> 确定</button>

                                    <button type="button" onclick="quit()" class="btn btn-sm btn-default"><i class="fa fa-times"></i> 取消</button>
                                </div>
                                <!--富文本编辑器结束-->
                                <div id="p">

                                    <div th:each="q : ${questionObject.getQuestionItemObjects()}">
                                        <div class="form-group" >
                                            <input style="display: none" id="size" th:value="${size}" name="size">
                                            <label for="subject" class="a" th:text="${q.getPrefix()}"></label>
                                            <input type="text" th:value="${q.getContent()}" tabindex="1" th:id="${q.getPrefix()}" class="form-control" th:name="${q.getPrefix()}" onclick="editMo(this.id,this.value)" required>
                                        </div>
                                    </div>


                                    <!--                                    <div class="form-group">-->
                                    <!--                                        <input style="display: none" id="size" th:value="${size}">-->
                                    <!--                                        <label for="subject" class="a">A</label>-->
                                    <!--                                        <input type="text" th:value="${questionObject.getQuestionItemObjects()[0].getContent()}" tabindex="1" id="A" class="form-control" name="A" required>-->
                                    <!--                                    </div>-->

                                    <!--                                    <div class="form-group">-->
                                    <!--                                        <label for="subject" class="a">B</label>-->
                                    <!--                                        <input type="text" th:value="${questionObject.getQuestionItemObjects()[1].getContent()}" tabindex="1" id="B" class="form-control" name="B" required>-->
                                    <!--                                    </div>-->

                                    <div class="form-group" id="cloneForm" style="display: none">
                                        <label for="subject" class="a" >C</label>
                                        <input type="text"  tabindex="3"  class="form-control"  >
                                    </div>

                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >D</label>-->
                                    <!--                                        <input type="text" th:value="${questionObject.getQuestionItemObjects()[3].getContent()}" tabindex="1" id="D"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >E</label>-->
                                    <!--                                        <input type="text"  th:value="${size>=4}?${questionObject.getQuestionItemObjects()[4].getContent()}:${null}" tabindex="1" id="E"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >F</label>-->
                                    <!--                                        <input type="text" th:value="${size>=4}?${questionObject.getQuestionItemObjects()[5].getContent()}:${null}" tabindex="1" id="F"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >G</label>-->
                                    <!--                                        <input type="text" th:value="${size>=4}?${questionObject.getQuestionItemObjects()[6].getContent()}:${null}" tabindex="1" id="G"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >H</label>-->
                                    <!--                                        <input type="text" th:value="${size>=4}?${questionObject.getQuestionItemObjects()[7].getContent()}:${null}" tabindex="1" id="H"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >I</label>-->
                                    <!--                                        <input type="text"  th:value="${size>=4}?${questionObject.getQuestionItemObjects()[8].getContent()}:${null}" tabindex="1" id="I"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->
                                    <!--                                    <div class="form-group" >-->
                                    <!--                                        <label for="subject" class="a" >J</label>-->
                                    <!--                                        <input type="text" th:value="${size>=4}?${questionObject.getQuestionItemObjects()[9].getContent()}:${null}" tabindex="1" id="J"  class="form-control" name="D" required>-->
                                    <!--                                    </div>-->

                                </div>

                                &nbsp;
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">答案</label>
                                    <input class="hidden" id="hiddenKey" th:value="${questionEditVM.getCorrect()}">
                                    <div class="col-sm-9 icheck ">
                                        <!--                                        <div th:each="q : ${questionObject.getQuestionItemObjects()}">-->
                                        <!--                                            <div class="flat-grey ">-->
                                        <!--                                                <div class="radio " >-->
                                        <!--                                                    <input tabindex="3" type="radio"  name="correct" th:id="'r_'+${q.getPrefix()}" th:value="${q.getPrefix()}">-->
                                        <!--                                                    <a th:text="${q.getPrefix()}"></a>-->
                                        <!--                                                </div>-->
                                        <!--                                            </div>-->
                                        <!--                                        </div>-->

                                        <div class="flat-grey ">
                                            <div class="checkbox" >
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_A" value="A">
                                                A
                                            </div>
                                        </div>
                                        <div class="flat-red ">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox" name="correct" id="r_B" value="B">
                                                B
                                            </div>
                                        </div>

                                        <div class="flat-green ">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox" name="correct" id="r_C" value="C">
                                                C
                                            </div>
                                        </div>

                                        <div class="flat-blue hidden" id="choice_D">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_D" value="D">
                                                D
                                            </div>
                                        </div>

                                        <div class="flat-yellow hidden" id="choice_E">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_E" value="E">
                                                E
                                            </div>
                                        </div>

                                        <div class="flat-purple hidden" id="choice_F">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_F" value="F">
                                                F
                                            </div>
                                        </div>
                                        <div class="flat-purple hidden" id="choice_G">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_G" value="G">
                                                G
                                            </div>
                                        </div>
                                        <div class="flat-purple hidden" id="choice_H">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_H" value="H">
                                                H
                                            </div>
                                        </div>
                                        <div class="flat-purple hidden" id="choice_I">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_I" value="I">
                                                I
                                            </div>
                                        </div>
                                        <div class="flat-purple hidden" id="choice_J">
                                            <div class="checkbox ">
                                                <input tabindex="3" type="checkbox"  name="correct" id="r_J" value="J">
                                                J
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!--                                <div class="form-group">-->
                                <!--                                    <label for="bcc" class="">答案</label>-->
                                <!--                                    <input type="text" tabindex="2" id="Key" class="form-control">-->
                                <!--                                </div>-->

                                <div class="form-group">
                                    <label  class="">解析</label>
                                    <input type="text" th:value="${questionObject.getAnalyze()}" name="analysis" tabindex="2" id="Answer" class="form-control" required>
                                </div>


                                <!--                                题型开始-->
                                <div class="form-group" id="">
                                    <label  class="">分类</label>
                                    <div class="btn-group">
                                        <select class="form-control" id="typenums">
                                            <option th:each="type :${typeList}" th:selected="${questionEditVM.getQuestionPool()} == ${type.getQPool()}" id="typeList" th:value="${type.getQPool()}" th:text="${type.getQType()}" ></option>
                                        </select>
                                    </div>
                                </div>
                                <input type="hidden" id="questionPoolValue" name="questionPoolValue" th:value="${questionEditVM.getQuestionPool()}"/>
                                <!--                                题型结束-->
                                <br>

                                <!--                                分数开始-->
                                <div class="form-group">
                                    <label  class="">分数</label>
                                    <div id="spinner4">
                                        <div class="input-group" style="width:150px;">
                                            <div class="spinner-buttons input-group-btn">
                                                <button type="button" class="btn spinner-up btn-primary">
                                                    <i class="fa fa-plus"></i>
                                                </button>
                                            </div>
                                            <input type="text" th:value="${questionEditVM.getScore()}" name="score" id="score" class="spinner-input form-control" maxlength="3" style="text-align: center;">
                                            <div class="spinner-buttons input-group-btn">
                                                <button type="button" class="btn spinner-down btn-warning">
                                                    <i class="fa fa-minus"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!--                                分数结束-->
                                <!--                                难度选择开始-->
                                <div class="form-group">
                                    <input class="hidden" id="diff" th:value="${questionEditVM.getDifficult()}">
                                    <label  class="">难度</label>
                                    <div class="btn-group btn-group-justified" style="width: 90%">
                                        <a class="btn btn-success" type="button" name="b1" onclick="cd1()" id="b1" value="1" style="width:20%">简单</a>
                                        <a class="btn btn-info" type="button" name="b2" onclick="cd2()"  id="b2" value="2" style="width:29%" >中等</a>
                                        <a class="btn btn-danger" type="button" name="b3" onclick="cd3()"  id="b3" value="3" style="width:39%">困难</a>
                                        <a class="btn btn-default hidden" type="button" name="b32" onclick="cd4()"  id="b4" >重置</a>
                                        <input type="text" name="difficult" style="display: none" id="nd" value='1' >
                                    </div>
                                </div>
                                &nbsp;
                                <!--难度选择结束-->
                                <!--题型开始-->
                                <input name="questionType" style="display: none" value="2">
                                <!--题型结束-->

                                <!--充当换行-->
                                <div class="form-group " style="display: none"></div>

                                <div class="compose-btn1">
                                    <button type="submit" class="btn btn-sm btn-info"><i class="fa fa-check"></i> 完成</button>
                                    <button type="button" onclick="reSetQuestion()" class="btn btn-sm btn-warning"><i class="fa fa-rotate-right"></i> 重置</button>
                                    <button type="button" class="btn btn-sm btn-success"
                                            onclick="addForm()"><i class="fa fa-plus"></i>添加选项</button>
                                    <button type="button" class="btn btn-sm btn-danger"
                                            onclick="reduceForm()"><i class="fa fa-minus"></i>减少选项</button>
                                </div>

                            </form>

                            <!--提示开始-->
                            <!--选项过多弹出框开始-->
                            <div class="col-md-12 ">
                                <a href="#myModal1" data-toggle="modal" class="btn btn-warning hidden" id="tip1">
                                    提示按钮
                                </a>
                                <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal1" class="modal fade" style="display: none;">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header" style="background:#bb1f1f">
                                                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                <h4 class="modal-title">提示</h4>
                                            </div>
                                            <div class="modal-body">
                                                最多十个选项
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--选项过多弹出框开始-->

                            <!--编辑model-->
                            <div class="col-md-12 ">
                                <a href="#editModel" data-toggle="modal" class="btn btn-warning hidden" id="edit">
                                    提示按钮
                                </a>
                                <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="editModel" class="modal fade" style="display: none;">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header" style="background:#F4C160">
                                                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                <h4 class="modal-title">编辑题干</h4>
                                            </div>
                                            <div class="email-rightbar mb-3">
                                                <div class="card">
                                                    <div class="card-body">
                                                        <form>
                                                            <div class="form-group">
                                                                <div class="summernote">

                                                                </div>
                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-sm btn-danger" data-dismiss="modal">取消</button>
                                                                <button type="button"  class="btn btn-primary btn-sm" data-dismiss="modal" onclick="getcontent()">确定</button>
                                                            </div>
                                                        </form>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 编辑结束-->

                            <!--选项过少弹出框开始-->
                            <div class="col-md-12 ">
                                <a href="#myModal2" data-toggle="modal" class="btn btn-warning hidden" id="tip2">
                                    提示按钮
                                </a>
                                <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal2" class="modal fade" style="display: none;">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header" style="background:#F4C160">
                                                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                <h4 class="modal-title">提示</h4>
                                            </div>
                                            <div class="modal-body">
                                                最少三个选项
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--弹出框结束-->
                            <!--提示结束-->
                        </div>
                    </section>
                </section>
            </div>

        </div>
        <!--footer section start-->
        <footer>
            2022 &copy;平顶山学院软件应用双创实验室提供技术支持
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<div th:replace="~{admin/commons/common :: commonupdatePwd}"></div>

<!-- Placed js at the end of the document so the pages load faster -->
<script src="/js/jquery-1.10.2.min.js"></script>
<script src="/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="/js/jquery-migrate-1.2.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/modernizr.min.js"></script>
<script src="/js/jquery.nicescroll.js"></script>

<script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>

<!--spinner-->
<script type="text/javascript" src="/js/fuelux/js/spinner.min.js"></script>
<script src="/js/spinner-init.js"></script>

<!--<script type="text/javascript" src="/js/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script>-->
<!--<script type="text/javascript" src="/js/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>-->
<!--icheck -->
<script src="/js/iCheck/jquery.icheck.js"></script>
<script src="/js/icheck-init.js"></script>

<!-- 富文本编辑器 -->

<script src="/js/summernote/summernote-bs4.min.js"></script>
<!--common scripts for all pages-->
<script src="/js/scripts.js"></script>

<script>





    //点击显示编辑器
    function editMo(type,html) {
        clickInput = type
        clickInputVal = html
        document.getElementById('edit').click()
        $('.summernote').summernote('code', html);
    }

    var clickInput = null;
    var clickInputVal = null;
    <!--初始化编辑器-->
    jQuery(document).ready(function(){

        $('.summernote').summernote({
            height: 200, // set editor height
            minHeight: null,             // set minimum height of editor
            maxHeight: null,             // set maximum height of editor
            focus: false,           // set focus to editable area after initializing summernote
            lang: 'zh-CN',
            callbacks: {
                onImageUpload: function(files, editor, $editable) {
                    uploadSummerPic(files[0], editor, $editable);
                },
                onMediaDelete: function(target) {
                    deleteFile(target);
                }
            }
        });
    });

    function uploadSummerPic(file, editor, $editable) {
        var fd = new FormData();
        fd.append("file", file);
        $.ajax({
            type:"POST",
            url:"/pic/uploadSummerPic",
            data: fd,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                alert(data.msg)
                //编辑器回显图片
                $('.summernote').eq(0).summernote('insertImage', data.data)
            }
        });
    }

    //定义deleteFile()
    function deleteFile(target){
        var deleteImg = target[0].currentSrc;
        urls = deleteImg.split('/')
        url = urls.pop()
        var data = new FormData();
        data.append("deleteImg", url);
        $.ajax({
            data: data,
            type: "POST",
            url:  "/pic/removeFile", //执行请求
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                alert(data.data)
            }
        });
    }

    //点击模态框确定后
    function getcontent() {
        var markupHTML = $('.summernote').summernote('code');//获取编辑的内容
        $("#"+clickInput).attr('value',markupHTML)//设置题干的文本内容为富文本编辑器的内容
        $('.summernote').summernote('code', null);
    }

    document.getElementById("question-list").className="active";
    document.getElementById("menu4").className="menu-list nav-active";
    //点击取消触发
    function quit(){
        $('#textarea').parent().addClass('hidden');//设置文本编辑器不可见，
        $('#textarea-button').addClass('hidden');//设置按钮不可见，设置题干可见
        $('#subject2').parent().removeClass('hidden')
    }

    //页面初始化加载
    $(document).ready( function() {
        var arr = ['A','B','C','D','E', 'F', 'G', 'H','I','J']
        //通过类获取选项的个数
        var num = document.getElementsByClassName('a').length-1
        var key = document.getElementById('hiddenKey').value
        for(var i = 0;i<num;i++){
            //将该表单对应的选项设置为可见
            $("#choice_"+arr[i]).removeClass('hidden')
            //答案中是否含有指定的答案，如果有就显示
            if (key.includes(arr[i])){
                $("#r_"+arr[i]+"").parent().addClass('checked')
            }

        }
        var diff = $('#diff').val()
        if(diff==1){
            cd1()
        }
        else if (diff==2){
            cd2()
        }
        else if(diff==3){
            cd3()
        }
        else {
            cd4()
        }
    });

    $("#typenums").change(function(){
        state = $('#typenums option:selected').val();
        $("#questionPoolValue").val(state)
    })


    // 增加form表单、选项
    function addForm() {
        var arr1 = ['D','E', 'F', 'G', 'H','I','J'];
        //通过类获取选项的个数
        var num = document.getElementsByClassName('a').length-1
        //设置选项数目最多不能大于10个选项
        if(num<10){
            // alert(document.getElementsByClassName('a').length)
            //获取要克隆的节点
            var cloneFrom = document.getElementById('cloneForm')
            //他的属性全部会被克隆
            var clone = document.getElementById('cloneForm').cloneNode(true)
            //设置选项name属性，label标签的文本内容通过动态获取jquery的id设置的
            clone.childNodes[1].innerHTML = arr1[num-3]
            clone.childNodes[3].id=arr1[num-3]
            clone.style=""
            // alert(clone.childNodes[1].innerHTML)
            //获取父节点，用来将子节点追加到其后
            var p = document.getElementById('p')
            p.appendChild(clone)
            //最后在修改name属性value属性（放在前面不生效，巨坑）
            $("#"+arr1[num-3]+"").attr('name',arr1[num-3]).attr('value',null)
            document.getElementById(arr1[num-3]).onclick=    function () {
                clickInput = arr1[num-3]
                clickInputVal = document.getElementById(arr1[num-3]).value
                document.getElementById('edit').click()
                $('.summernote').summernote('code', document.getElementById(arr1[num-3]).value);
            }
            //将该表单对应的选项设置为可见
            $("#choice_"+arr1[num-3]+"").removeClass('hidden')
        }
        //大于十个选项设置提示
        else{
            document.getElementById("tip1").click()
        }
    }


    //减少Form表单、选项
    function reduceForm(){
        $('#tip1').addClass('hidden')
        var arr1 = ['D','E', 'F', 'G', 'H','I','J'];
        var num = document.getElementsByClassName('a').length-1
        if(num<4){
            //弹出提示框
            document.getElementById("tip2").click()
        }
        else{//js写的，获取该节点，用js获取的用jquery也能获取，见上文
            var d =  document.getElementsByName(arr1[num-4])[0]
            //将该节点对应的选项设置为不可见
            $("#choice_"+arr1[num-4]+"").addClass('hidden')
            //移除该节点
            var dp=d.parentNode
            dp.remove()
        }
    }
    //对点击按钮的操作
    function cd1() {
        $('#nd').val(1)
        $('#b2').addClass('hidden')
        $('#b3').addClass('hidden')
        $(this).attr("name",1)
        $('#b4').css("width","68%").removeClass('hidden')
        // $('#b4').removeClass('hidden')
    }
    function cd2() {
        $('#nd').val(2)
        $('#b1').addClass('hidden')
        $('#b3').addClass('hidden')
        $(this).attr("name",2)
        $('#b4').css("width","59%").removeClass('hidden')
    }
    function cd3() {
        $("#nd").attr("value",'3')
        $('#b1').addClass('hidden')
        $('#b2').addClass('hidden')
        $(this).attr("name",3)
        $('#b4').css("width","48%").removeClass('hidden')
    }
    function cd4() {
        $('#nd').val(3)
        $('#b1').removeClass('hidden')
        $('#b2').removeClass('hidden')
        $('#b3').removeClass('hidden')
        $('#b4').addClass('hidden')
    }
    //重置函数
    function reSetQuestion() {
        //移除选定状态
        var arrR =['A','B','C','D','E','F','G','H','I','J']
        for(var i=0; i<arrR.length; i++){
            if(($("#r_"+arrR[i]+"").parent())!=null){
                $("#r_"+arrR[i]+"").parent().removeClass('checked')
            }

        }
        //将默认文本框的值设置为空
        $('#to').attr('value',null)
        $('#subject').attr('value',null)
        $('#subject2').attr('value',null)
        $('#Answer').attr('value',null)
        $('#A').attr('value',null)
        $('#B').attr('value',null)
        $('#C').attr('value',null)
        $('#D').attr('value',null)
        $('#score').attr('value',0)
        cd4()
        //获取input的个数
        var len = document.getElementsByClassName('a').length-1
        if(len==3){
            //调用增加的函数增加一个表单
            addForm()
        }
        else if(len==4){//如果等于4什么也不做
        }
        else{//不等于4把多余的清除
            var arr1 = ['D','E', 'F', 'G', 'H','I','J'];
            var s = len-4//剩余的个数
            for(var i=0;i<s;i++){//用循环把所有多余的节点全删了
                //调用减少的函数减少几次
                reduceForm();
            }
        }
    }


    // 修改密码
    $("#pwd_btn").click(function() {
        $("#pwd_btn").blur();
        if (confirm("是否确定修改?")){
            var submit = true;
            var oldPwd = $("#oldPwd").val(); //原始密码
            var newPwd = $("#newPwd").val(); //新密码1
            var newPwd2 = $("#newPwd2").val(); //新密码2

            if ((oldPwd && newPwd && newPwd2) == '') {
                $("#tip").html("密码不能为空");
                $("#tip").show();
                submit = false;
            }
            if(submit){
                $.ajax({
                    type:"post",
                    url:"/admin/updatePwd",
                    data: JSON.stringify({
                        oldPwd : oldPwd,
                        newPwd : newPwd,
                        newPwd2 : newPwd2
                    }),
                    contentType: "application/json;charset=utf-8",
                    //定义回调响应的数据格式为JSON字符串，该属性可以省略
                    dataType: "json",
                    success:function (data){
                        if(data.code == 200 ){
                            $("#tip").hide();
                            $("#pwd_form").submit();
                            alert("修改成功，请重新登录!")
                            window.location.href = "/user/logout"
                        }else if(data.code != 200){
                            $("#tip").html(data.info);
                            $("#tip").show();
                        }
                    }
                });
            }
        }
    });

    jQuery(document).ready(function(){
        $('.wysihtml5').wysihtml5();
    });

</script>

</body>
</html>
